#include <vector>
#include <algorithm>

using namespace std;

typedef vector< short>   vint; 
typedef vector< vector<short> > vvint;
typedef vector< vector< vector<short> > > vvvint;

#define min_(X,Y) X == 0 ? 0 : (X < Y ? X : Y)

short cota;

short wayClosestTarget(short i, short j, short target, vvint& matriz, vvvint& mem) {
	if (target > cota) return cota;
	
	if (mem[i][j][target] >= 0) return mem[i][j][target];

    short& actual = matriz[i][j];

	short distancia1 = target - actual;
	short distancia2 = target + actual;
    if (distancia1 < 0) distancia1 *= -1;
    if (distancia2 < 0) distancia2 *= -1;
	if ( i==0 && j==0 ) {
		return distancia1 < distancia2 ? distancia1 : distancia2;
	} else {
		short res;
		if ( i==0 || j==0 ) {
			if (i == 0) { // j > 0
                res = min_(wayClosestTarget(i, j-1, distancia1, matriz, mem), wayClosestTarget(i, j-1, distancia2, matriz, mem));
                mem[i][j][target] = res; 
				return res;
			} else { // i> 0
                res = min_(wayClosestTarget(i-1, j, distancia1, matriz, mem), wayClosestTarget(i-1, j, distancia2, matriz, mem));
                mem[i][j][target] = res;
				return res;
			}	
		} else {  // i > 0 y j > 0
            res = min(
                    min_(wayClosestTarget(i, j-1, distancia1, matriz, mem), wayClosestTarget(i, j-1, distancia2, matriz,mem)),
                    min_(wayClosestTarget(i-1, j, distancia1, matriz, mem), wayClosestTarget(i-1, j, distancia2, matriz, mem))
                    );
            mem[i][j][target] = res;
            return res; 
		}
	}
}

int main() {
	
    short n;
    scanf ("%hd",&n);
    
    while ( n != 0 ) {
        vvint matriz(n, vint(n, 0));
        short cantElem = 0;
        short maxpiramide = 0;
		short valor;
		short x, y;    
        for( short i = 0; i < (2*n - 1); ++i ){
            
            i < n ? ++cantElem : --cantElem;
    
            for( short j = 0; j < cantElem ; ++j ){
                scanf ("%hd",&valor);
                if (valor < 0) valor *= -1;
                if (i < n) {
                    y = i - j;
                    x = i - y;
                } else {
                    x = i + j - (n - 1);
                    y = i - x;
                }
                if (valor > maxpiramide) maxpiramide = valor;
                matriz[x][y] = valor;
            }
        }
        cota = n* maxpiramide;
		vvvint mem(n, vvint(n, vint(cota+1,-1)));
        printf("%hd\n", wayClosestTarget(n-1,n-1,0, matriz, mem));
		scanf ("%hd",&n);
    }
    
    return 0;
}


